package com.stardigi.workflowplatform.common;

public class Response<T> {

  private boolean success = true;

  private String msg;

  private T entity;

  public boolean isSuccess() {
    return success;
  }

  public void setSuccess(boolean success) {
    this.success = success;
  }

  public String getMsg() {
    return msg;
  }

  public void setMsg(String msg) {
    this.msg = msg;
  }

  public T getEntity() {
    return entity;
  }

  public void setEntity(T entity) {
    this.entity = entity;
  }

  public Response() {
  }

  public Response(boolean success) {
    this.success = success;
  }

  public Response(boolean success, String msg) {
    this.success = success;
    this.msg = msg;
  }

  public Response(boolean success, String msg, T entity) {
    this.success = success;
    this.msg = msg;
    this.entity = entity;
  }

  public static <T> Response success(T entity) {
    return new Response(true, null, entity);
  }

  public static Response fail(String message) {
    return new Response(false, message);
  }

}
